<template>
    <div class="new-email-submit">
        <TopTitleExit :exit="routerExit" title="Mount New Email"></TopTitleExit>
        <div class="new-email-submit-container">
            <div class="login-password">
                <div class="input-line">
                    <div class="k">New Email</div>
                    <div class="v">
                        <input type="text" v-model="emailAddressForm.new_email" placeholder="Enter your new email" />
                    </div>
                </div>
                <div class="btn-box">
                    <div class="btn" @click="JumpToChangeEmailVerifyCode_new">Submit</div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { reactive } from 'vue';
import TopTitleExit from '@/components/common/TopTitleExit.vue';
import { routerTo, routerExit } from '@/utils/jump';
import { loading, toast } from '@/service/status';
import { checkEmail } from '@/utils/input';

const emailAddressForm = reactive({
    old_email: '',
    old_email_verify_code: '',
    new_email: '',
    new_email_verify_code: '',
});

// 跳转到 修改绑定邮箱 新邮箱验证码页面
function JumpToChangeEmailVerifyCode_new() {
    let call = true;
    if (emailAddressForm.new_email == '') {
        call = false;
        toast.toast('Please enter your email address', 2000);
    } else if (!checkEmail(emailAddressForm.new_email)) {
        call = false;
        toast.toast('The email format is invalid', 2000);
    }
    if (call) {
        routerTo('/verify/verify_new_email');
    }
}
</script>

<style scoped lang="less">
.new-email-submit {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    .new-email-submit-container {
        box-sizing: border-box;
        width: 100vw;
        flex: 1;
        padding: 5vw;

        .login-password {
            width: 100%;
            display: flex;
            flex-direction: column;
            gap: 4vw;

            .input-line {
                width: 100%;
                display: flex;
                flex-direction: column;
                gap: 2.5vw;

                .k {
                    font-size: 3.2vw;
                    font-weight: 500;
                    color: var(--text-color);
                }

                .v {
                    box-sizing: border-box;
                    width: 100%;
                    display: flex;
                    align-items: center;
                    gap: 2vw;
                    border: 0.1vw solid var(--border-color);
                    border-radius: 2vw;
                    padding: 2vw;

                    input {
                        flex: 1;
                        height: 4vw;
                        border: 0;
                        outline: 0;
                        font-size: 3vw;
                    }

                    .icon {
                        --size: 4vw;
                        --w: var(--size);
                        --h: var(--size);
                    }
                }
            }

            .input-btn-line {
                width: 100%;
                display: flex;
                flex-direction: column;
                gap: 2.5vw;

                .k {
                    font-size: 3.2vw;
                    font-weight: 500;
                    color: var(--text-color);
                }

                .v {
                    display: flex;
                    gap: 2vw;

                    .input-box {
                        box-sizing: border-box;
                        width: 100%;
                        display: flex;
                        align-items: center;
                        gap: 2vw;
                        border: 0.1vw solid var(--border-color);
                        border-radius: 2vw;
                        padding: 2vw;

                        input {
                            flex: 1;
                            height: 4vw;
                            border: 0;
                            outline: 0;
                            font-size: 3vw;
                        }
                    }

                    .btn {
                        box-sizing: border-box;
                        height: 100%;
                        padding: 1vw 2vw;
                        display: flex;
                        justify-content: center;
                        align-items: center;
                        border-radius: 2vw;
                        background-color: var(--active-color);

                        .text {
                            font-size: 3vw;
                            color: #fff;
                        }
                    }
                }
            }

            .warn-box {
                box-sizing: border-box;
                width: 100%;
                padding: 5vw;
                background-color: var(--warn-bg-color);
                border-radius: 2vw;
                display: flex;
                gap: 2vw;

                .icon {
                    --size: 5vw;
                    --w: var(--size);
                    --h: var(--size);
                    font-size: calc(var(--size) * 0.8);
                    text-align: center;
                    line-height: var(--size);
                    color: var(--active-color);
                }

                .text {
                    flex: 1;
                    font-size: 3vw;
                    color: var(--text-color);
                }
            }

            .btn-box {
                margin-top: 10vw;
                width: 100%;

                .btn {
                    --h: 11vw;
                    width: 100%;
                    height: var(--h);
                    border-radius: 2vw;
                    background-color: var(--active-color);
                    color: #fff;
                    font-size: 3.5vw;
                    font-weight: 500;
                    text-align: center;
                    line-height: var(--h);
                }
            }
        }
    }
}
</style>